package com.winning.yanghao.designpattern.singleton.doublecheck;

/**
 * 双重检查锁，这样能保证上锁的次数减少，提升性能
 */
public class DoubleCheck {

    private DoubleCheck(){}

    private static DoubleCheck instance = null;

    public static DoubleCheck getInstance(){
        if(instance == null){
            synchronized (DoubleCheck.class){
                if(instance == null){
                    instance = new DoubleCheck();
                }
            }
        }

        return instance;
    }

}
